﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:RawExplorer2.UI">
	<DataTemplate x:Key="CharCodeArgDataTemplate">
		<Grid x:Name="ColorNumberPicker">
			<Grid x:Name="EditorField"
			      Width="Auto"
			      HorizontalAlignment="Stretch">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="32" />
				</Grid.ColumnDefinitions>
				<TextBox HorizontalAlignment="Stretch">
					<TextBox.Text>
						<Binding Mode="TwoWay"
						         Path="Value"
						         UpdateSourceTrigger="PropertyChanged">
							<Binding.ValidationRules>
								<local:CharCodeRule />
							</Binding.ValidationRules>
						</Binding>
					</TextBox.Text>
				</TextBox>
				<ToggleButton x:Name="DropdownToggle"
				              Grid.Column="1"
				              HorizontalAlignment="Stretch"
				              IsChecked="{Binding Path=IsEditorOpen,
				                                  Mode=TwoWay,
				                                  UpdateSourceTrigger=PropertyChanged}"
				              IsHitTestVisible="{Binding ElementName=ColorNumberPopup,
				                                         Path=IsOpen,
				                                         Converter={local:BooleanInverterConverter},
				                                         Mode=OneWay}">
					<Path Width="6"
					      Margin="4"
					      HorizontalAlignment="Center"
					      VerticalAlignment="Center"
					      Data="{StaticResource DropDownPath}"
					      Fill="#FF527DB5"
					      Stretch="Uniform" />
				</ToggleButton>
			</Grid>
			<Popup x:Name="ColorNumberPopup"
			       AllowsTransparency="True"
			       HorizontalOffset="{Binding RelativeSource={RelativeSource Self},
			                                  Converter={local:RightAlignedPopupOffsetConverter}}"
			       IsOpen="{Binding Path=IsEditorOpen,
			                        Mode=TwoWay,
			                        UpdateSourceTrigger=PropertyChanged}"
			       Placement="Bottom"
			       PlacementTarget="{Binding ElementName=ColorNumberPicker}"
			       PopupAnimation="Slide"
			       StaysOpen="False">
				<Border Margin="0,0,8,8">
					<Border.Effect>
						<DropShadowEffect />
					</Border.Effect>
					<local:TilePicker SelectedIndex="{Binding Path=Value, Converter={local:CharCodeToIntegerConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
				</Border>
			</Popup>
		</Grid>
	</DataTemplate>
</ResourceDictionary>
